#ifndef IMAGEWINDOW_HPP_INCLUDED
#define IMAGEWINDOW_HPP_INCLUDED

#include <gtkmm.h>
#include <libglademm.h>
#include <string>
class MainWindow;
#include "principalwindow.hpp"
#include "objects.hpp"
#include "contourwindow.hpp"
#include "IRS.h"

class CustomWindow : public Gtk::Window{
    protected:
    public:
        friend class ImageWindow;
        friend class ContourWindow;
        friend class DataWindow;
        CustomWindow (BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade):Gtk::Window(cobject){
        }
        virtual ~CustomWindow (){
        }
    protected:
};

class ImageWindow : public Objects{

    //Main window
    MainWindow *principalwindow;

    //GUI objects
    CustomWindow *imagewindow;
    Gtk::ImageMenuItem *menusave;
    Gtk::Image *image;
    Gtk::MenuItem *menuconvert;
    Gtk::MenuItem *menuerosion;
    Gtk::MenuItem *menudilation;
    Gtk::MenuItem *menuopening;
    Gtk::MenuItem *menuclosing;
    Gtk::MenuItem *menuinvert;
    Gtk::MenuItem *menuskel;
    Gtk::MenuItem *menuundo;
    Gtk::MenuItem *menuextremities;
    Gtk::MenuItem *menuneighbourvalue;
    Gtk::MenuItem *menudensity;
    Gtk::MenuItem *menucontour;
    Gtk::ToggleButton *x1;
    Gtk::ToggleButton *x4;
    Gtk::EventBox *eventboximage;


    //interface image
    Glib::RefPtr<Gdk::Pixbuf> *interfaceimage;
    Glib::RefPtr<Gdk::Pixbuf> *interfaceimage4x;

    //popup menu
    Glib::RefPtr<Gtk::UIManager> UIManager;
    Glib::RefPtr<Gtk::ActionGroup> ActionGroup;
    Gtk::Menu* MenuPopup;
    unsigned int mousex;
    unsigned int mousey;


    //Image
    Image* workimage;
    //Image for undo
    Image* undoimage;

    //pré-information;
    PositionMap* crossmap;

    //true if has undo
    bool hasundo;
    //true if has zoom
    bool zoom;

    //image path in HD(if has)
    std::string imagepath;

    //saida de imagens de funções, troca ou cria nova janela
    void outImage(Image* img);

    public:
    //constructors
    ImageWindow(string imgpath,MainWindow* main);
    ImageWindow(Image* img,MainWindow* main);

    //destructors
    ~ImageWindow();

    //retorna imagem ativa na janela
    Image* getImage();

    //retorna tipo da imagem
    string getImageType();

    //diz se a imagem está em zoom(4x) ou não
    bool hasZoom();

    //Função que avisa erro de tipo de imagem
    void invalidtyperror();

    //Fecha imagem
    virtual bool close(GdkEventAny *);

    //image operations
    virtual void convertimage();
    virtual void erosion();
    virtual void dilation();
    virtual void openning();
    virtual void closing();
    virtual void invert();
    virtual void save();
    virtual void skel();
    virtual void imagedensity();
    virtual void undo();
    virtual void neighbourvalue();
    virtual void getextremities();
    virtual void extractcontour();
    virtual void zoom1x();
    virtual void zoom4x();
    virtual void getcontour();
    virtual void testfunction();


    //popup menu option
    virtual bool openpopup(GdkEventButton* event);
    virtual void forcetobifurcation();
    virtual void forcetocrossing();
    virtual void forcetosuperposition();
    virtual void forcenone();

};

#endif // IMAGEWINDOW_HPP_INCLUDED
